package com.sc.vipface.utils;

import com.sc.vipface.configs.SysSettings;
import com.sc.vipface.entity.dto.AdapterDto;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DtoUtils {
    public static AdapterDto getAdapterDto(SysSettings settings) {
        var adapterDto = new AdapterDto();
        adapterDto.setUid(settings.getUid());
        adapterDto.setName(settings.getName());
        adapterDto.setPlatformId(settings.getVendorPlatformId());
        adapterDto.setModelId(settings.getDeviceModelId());
        adapterDto.setDeviceType(settings.getDeviceType());
        adapterDto.setDescription("海康视频服务");

        return adapterDto;
    }

    public static AdapterDto createAdapterDto(LocalDateTime dataTime, SysSettings settings) {
        var result = getAdapterDto(settings);

        if (dataTime != null) {
            String dateStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
            result.setLastDataTime(dateStr);
        }
        return result;
    }


}
